import { getlink } from "@/api/getapi.js"
import { loggetlink } from "@/api/loggetapi.js"

export let mym = {
    state: {
        arr: {},
        str: []
    },
    mutations: {
        dataLoading(state, payload) {
            // console.log(payload)
            state.arr = payload
        },
        stritem(state, payload) {
            // console.log(payload)
            state.str = payload
        }
    },
    actions: {
        mymData(context, payload) {
            getlink(payload.url).then((ok) => {
                // console.log(ok.data)
                context.commit("dataLoading", ok.data)
            }).catch((err) => {
                console.log("失败", err)
            })
        },
        dataper(context, payload) {
            getlink(payload.url).then((ok) => {
                console.log(ok)
                context.commit("stritem", ok)
            }).catch((err) => {
                console.log("失败", err)
            })
        },
        // 登出操作
        nolog(context, payload) {
            loggetlink(payload.url, payload.aaa).then((ok) => {
                console.log(context, ok.data)
                window.localStorage.setItem("login", false)
                window.localStorage.removeItem("token")
                window.localStorage.removeItem("token")


            }).catch((err) => {
                console.log("失败", err)
            })
        },
    },

}